<template>
	<!--此版本无登录功能-->
  <view class="login-container">
    <view class="login-form">
      <view class="logo-container">
        <h2>温室卷帘门控制系统</h2>
      </view>
      <view class="logo-container">
        <image src="/static/logo.png" class="login-logo" />
      </view>
      <view class="input-group">
        <text class="label">用户名</text>
        <view class="input-field">
          <input type="text" placeholder="请输入用户名" v-model="username" />
        </view>
      </view>
      <view class="input-group">
        <text class="label">密码</text>
        <view class="input-field">
          <input type="password" placeholder="请输入密码" v-model="password" />
        </view>
      </view>
      <button class="login-button" @click="login">登录</button>
      <view class="register-link">
        <!-- 为忘记密码和注册账号添加点击事件 -->
        <text class="link-text" @click="navigateToRegister">忘记密码？</text>
        <text class="link-text" @click="navigateToRegister">注册账号</text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      username: '', // 用户名绑定
      password: '' // 密码绑定
    };
  },
  methods: {
    login() {
      // 验证用户名和密码是否为空
      if (!this.username || !this.password) {
        uni.showToast({
          title: '用户名和密码不能为空',
          icon: 'none'
        });
        return;
      }
      // 这里可以添加实际的登录请求逻辑，例如使用 uni.request 发送请求到后端服务器
      console.log(`用户名: ${this.username}, 密码: ${this.password}`);
      // 假设登录成功，给出提示并跳转页面
      uni.showToast({
        title: '登录成功',
        icon: 'success'
      });
      // 添加页面跳转逻辑
      uni.reLaunch({
        url: '/pages/index/index'
      });
    },
    // 定义跳转方法
    navigateToRegister() {
      uni.navigateTo({
        url: '/pages/register/register001' 
      });
    }
  },
};
</script>

<style scoped>
/* 清除默认样式 */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-color: #f5f5f5;
  padding: 20px;
  box-sizing: border-box;
}

.login-form {
  background-color: #ffffff;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.logo-container {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto;
}

.input-group {
  margin-bottom: 16px;
}

.label {
  display: block;
  font-size: 14px;
  color: #666;
  margin-bottom: 8px;
}

.input-field {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px;
  box-sizing: border-box;
}

.login-button {
  width: 100%;
  padding: 10px;
  background-color: #007bff;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 16px;
}

.login-button:active {
  background-color: #0056b3;
}

.register-link {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #007bff;
}

.link-text {
  text-decoration: none;
  cursor: pointer;
}

.link-text:hover {
  text-decoration: underline;
}
</style>